home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / MacInterface / scrap.icl < prev    next >
Encoding:
Modula Implementation  |  1997-01-08  |  1.6 KB  |  42 lines  |  [TEXT/3PRM]

  1. implementation module scrap;
  2.  
  3. import mac_types, StdArray;
  4.  
  5. NoScrapErr            :==    -100;            // desk scrap isn't initialized
  6. NoTypeErr            :==    -102;            // no data of the requested type
  7.  
  8. ScrapSize            :==    2400;            // $960 (Long)        size in bytes of desk scrap
  9. ScrapHandle            :==    2404;            // $964 (Long)        handle to desk scrap in memory
  10. ScrapCount            :==    2408;            // $968 (Word)        count changed by ZeroScrap
  11. ScrapState            :==    2410;            // $96A (Word)        tells where desk scrap is
  12. ScrapName            :==    2412;            // $96C (Sting256)    pointer to scrap filename (preceded by length byte)
  13.  
  14. TextResourceType    :== 0x54455854;        // 'TEXT'
  15. PictResourceType    :== 0x50494354;        // 'PICT'
  16.  
  17. //    Writing to the Desk Scrap
  18. ZeroScrap :: !Toolbox -> (!Int,!Toolbox);
  19. ZeroScrap tb = code (tb=R4U)(result=L,z=Z){
  20.     instruction 0xA9FC        | _ZeroScrap
  21. };
  22.  
  23. PutScrap :: !Int !Int !Ptr !Toolbox -> (!Int,!Toolbox);
  24. PutScrap length theType source tb = code (length=R4L,theType=L,source=L,tb=U)(result=L,z=Z){
  25.     instruction 0xA9FE        | _PutScrap
  26. };
  27.  
  28. PutScrapText :: !{#Char} !Toolbox -> (!Int,!Toolbox);
  29. PutScrapText sourceText tb = PutScrapText1 (size sourceText) TextResourceType sourceText tb;
  30.  
  31. PutScrapText1 :: !Int !Int !{#Char} !Toolbox -> (!Int,!Toolbox);
  32. PutScrapText1 length theType sourceText tb = code (length=R4L,theType=L,sourceText=S,tb=U)(result=L,z=Z){
  33.     instruction 0x52AF 0x0000    |    addq.l #1,0(sp)
  34.     instruction 0xA9FE            |    _PutScrap
  35. };
  36.  
  37. //    Reading from the Desk Scrap
  38. GetScrap :: !Handle !Int !Toolbox -> (!Int,!Int,!Toolbox);
  39. GetScrap hDest theType tb = code (hDest=R8L,theType=L,tb=O12U)(result=L,offset=L,z=Z){
  40.     instruction    0xA9FD        | _GetScrap
  41. };
  42.